import 'package:kmxy_base/util/amap_location_util.dart';
import 'package:kmxy_base_example/page/amap_location/amap_location_page_state.dart';

import 'package:kmxy_base/base/base_package.dart';

class AmapLocationPageView extends AmapLocationPageState {
  @override
  Widget setPageContent(BuildContext context) {
    initMap();
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: const Text(
          '高德地图后台定位案例界面',
          style: TextStyle(
            color: Colors.white,
            fontWeight: FontWeight.w700,
          ),
        ),
      ),
      body: SafeArea(
        child: Stack(
          children: [
            SizedBox(
              height: heightScreen,
              width: widthScreen,
              child: map,
            ),
            Positioned(
              right: 0,
              child: Container(
                  width: 30,
                  height: 30,
                  alignment: Alignment.center,
                  color: Colors.white,
                  child: Text(
                      '${AMapLocationUtil.getInstance.locationData['satellite'] ?? '0'}')),
            ),
            Positioned(
              bottom: 0,
              child: Container(
                width: widthScreen,
                color: Colors.white,
                child: Column(
                  children: [
                    TextButton(
                        onPressed: () {
                          AMapLocationUtil.getInstance.startPatrol();
                        },
                        child: const Text("开始巡查")),
                    TextButton(
                        onPressed: () {
                          AMapLocationUtil.getInstance.endPatrol();
                          finishPop(context);
                        },
                        child: const Text("停止巡查")),
                    TextButton(
                        onPressed: () async {
                          // 本地存储巡查坐标数据
                          await SpUtil.delKey(
                              AMapLocationUtil.getInstance.SP_LATLNG_LIST);
                        },
                        child: const Text("清空巡查数据")),
                  ],
                ),
              ),
            ),
            Positioned(
              child: Container(
                width: widthScreen,
                color: Colors.white,
                child: Text(locationDataS),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
